
{% extends 'base/base.html' %}

{% block title %}{{ topic.name }} - 简易问答平台{% endblock %}

{% block content %}
<div class="page-header">
        {% autoescape off %}
         <h1>{{ topic.name }}</h1>
    <p class="lead">{{ topic.description }}</p>
        {% endautoescape %}

</div>

<div class="well">
    <p><strong>问题总数:</strong> {{ questions.count }}</p>
    <a href="{% url 'main:create_question' %}" class="btn btn-primary">发布新问题</a>
</div>

<h2>该话题下的问题</h2>

{% for question in questions %}
<div class="panel panel-default">
    <div class="panel-heading">
        <h3 class="panel-title">
            <a href="{% url 'main:question_detail' question.pk %}">{{ question.title }}</a>
        </h3>
    </div>
    <div class="panel-body">
        <p>{{ question.content|truncatechars:100 }}</p>
        <div class="text-muted">
            <p>提问者: {{ question.author.username }} | 
               发布时间: {{ question.created_at|date:"Y-m-d H:i" }} |
               回答数: {{ question.answer_set.count }}
            </p>
        </div>
    </div>
</div>
{% empty %}
<div class="alert alert-info">
    该话题下暂无问题，<a href="{% url 'main:create_question' %}">发布第一个问题</a>吧！
</div>
{% endfor %}
{% endblock %}
